﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace UIT.WPF.Converters
{
    class KeyConverter
    {
        public static Key Convert(UIT.Events.Keyboard.Keys key)
        {
            switch (key)
            {
                case UIT.Events.Keyboard.Keys.None:
                    return Key.None;
                case UIT.Events.Keyboard.Keys.Back:
                    return Key.Back;
                case UIT.Events.Keyboard.Keys.Tab:
                    return Key.Tab;
                case UIT.Events.Keyboard.Keys.LineFeed:
                    return Key.LineFeed;
                case UIT.Events.Keyboard.Keys.Clear:
                    return Key.Clear;
                case UIT.Events.Keyboard.Keys.Return:
                    return Key.Return;
                case UIT.Events.Keyboard.Keys.Shift:
                case UIT.Events.Keyboard.Keys.ShiftKey:
                    return Key.LeftShift | Key.RightShift;
                case UIT.Events.Keyboard.Keys.ControlKey:
                case UIT.Events.Keyboard.Keys.Control:
                    return Key.LeftCtrl | Key.RightCtrl;
                case UIT.Events.Keyboard.Keys.Alt:
                case UIT.Events.Keyboard.Keys.Menu:
                    return Key.LeftAlt | Key.RightAlt;
                case UIT.Events.Keyboard.Keys.Pause:
                    return Key.Pause;
                case UIT.Events.Keyboard.Keys.CapsLock:
                    return Key.CapsLock;
                case UIT.Events.Keyboard.Keys.KanaMode:
                    return Key.KanaMode;
                case UIT.Events.Keyboard.Keys.JunjaMode:
                    return Key.JunjaMode;
                case UIT.Events.Keyboard.Keys.FinalMode:
                    return Key.FinalMode;
                case UIT.Events.Keyboard.Keys.HanjaMode:
                    return Key.HanjaMode;
                case UIT.Events.Keyboard.Keys.Escape:
                    return Key.Escape;
                case UIT.Events.Keyboard.Keys.IMEConvert:
                    return Key.ImeConvert;
                case UIT.Events.Keyboard.Keys.IMENonconvert:
                    return Key.ImeNonConvert;
                case UIT.Events.Keyboard.Keys.IMEAccept:
                    return Key.ImeAccept;
                case UIT.Events.Keyboard.Keys.IMEModeChange:
                    return Key.ImeModeChange;
                case UIT.Events.Keyboard.Keys.Space:
                    return Key.Space;
                case UIT.Events.Keyboard.Keys.PageUp:
                    return Key.PageUp;
                case UIT.Events.Keyboard.Keys.PageDown:
                    return Key.Next;
                case UIT.Events.Keyboard.Keys.End:
                    return Key.End;
                case UIT.Events.Keyboard.Keys.Home:
                    return Key.Home;
                case UIT.Events.Keyboard.Keys.Left:
                    return Key.Left;
                case UIT.Events.Keyboard.Keys.Up:
                    return Key.Up;
                case UIT.Events.Keyboard.Keys.Right:
                    return Key.Right;
                case UIT.Events.Keyboard.Keys.Down:
                    return Key.Down;
                case UIT.Events.Keyboard.Keys.Select:
                    return Key.Select;
                case UIT.Events.Keyboard.Keys.Print:
                    return Key.Print;
                case UIT.Events.Keyboard.Keys.Execute:
                    return Key.Execute;
                case UIT.Events.Keyboard.Keys.Snapshot:
                    return Key.Snapshot;
                case UIT.Events.Keyboard.Keys.Insert:
                    return Key.Insert;
                case UIT.Events.Keyboard.Keys.Delete:
                    return Key.Delete;
                case UIT.Events.Keyboard.Keys.Help:
                    return Key.Help;
                case UIT.Events.Keyboard.Keys.D0:
                    return Key.D0;
                case UIT.Events.Keyboard.Keys.D1:
                    return Key.D1;
                case UIT.Events.Keyboard.Keys.D2:
                    return Key.D2;
                case UIT.Events.Keyboard.Keys.D3:
                    return Key.D3;
                case UIT.Events.Keyboard.Keys.D4:
                    return Key.D4;
                case UIT.Events.Keyboard.Keys.D5:
                    return Key.D5;
                case UIT.Events.Keyboard.Keys.D6:
                    return Key.D6;
                case UIT.Events.Keyboard.Keys.D7:
                    return Key.D7;
                case UIT.Events.Keyboard.Keys.D8:
                    return Key.D8;
                case UIT.Events.Keyboard.Keys.D9:
                    return Key.D9;
                case UIT.Events.Keyboard.Keys.A:
                    return Key.A;
                case UIT.Events.Keyboard.Keys.B:
                    return Key.B;
                case UIT.Events.Keyboard.Keys.C:
                    return Key.C;
                case UIT.Events.Keyboard.Keys.D:
                    return Key.D;
                case UIT.Events.Keyboard.Keys.E:
                    return Key.E;
                case UIT.Events.Keyboard.Keys.F:
                    return Key.F;
                case UIT.Events.Keyboard.Keys.G:
                    return Key.G;
                case UIT.Events.Keyboard.Keys.H:
                    return Key.H;
                case UIT.Events.Keyboard.Keys.I:
                    return Key.I;
                case UIT.Events.Keyboard.Keys.J:
                    return Key.J;
                case UIT.Events.Keyboard.Keys.K:
                    return Key.K;
                case UIT.Events.Keyboard.Keys.L:
                    return Key.L;
                case UIT.Events.Keyboard.Keys.M:
                    return Key.M;
                case UIT.Events.Keyboard.Keys.N:
                    return Key.N;
                case UIT.Events.Keyboard.Keys.O:
                    return Key.O;
                case UIT.Events.Keyboard.Keys.P:
                    return Key.P;
                case UIT.Events.Keyboard.Keys.Q:
                    return Key.Q;
                case UIT.Events.Keyboard.Keys.R:
                    return Key.R;
                case UIT.Events.Keyboard.Keys.S:
                    return Key.S;
                case UIT.Events.Keyboard.Keys.T:
                    return Key.T;
                case UIT.Events.Keyboard.Keys.U:
                    return Key.U;
                case UIT.Events.Keyboard.Keys.V:
                    return Key.V;
                case UIT.Events.Keyboard.Keys.W:
                    return Key.W;
                case UIT.Events.Keyboard.Keys.X:
                    return Key.X;
                case UIT.Events.Keyboard.Keys.Y:
                    return Key.Y;
                case UIT.Events.Keyboard.Keys.Z:
                    return Key.Z;
                case UIT.Events.Keyboard.Keys.LWin:
                    return Key.LWin;
                case UIT.Events.Keyboard.Keys.RWin:
                    return Key.RWin;
                case UIT.Events.Keyboard.Keys.Apps:
                    return Key.Apps;
                case UIT.Events.Keyboard.Keys.Sleep:
                    return Key.Sleep;
                case UIT.Events.Keyboard.Keys.NumPad0:
                    return Key.NumPad0;
                case UIT.Events.Keyboard.Keys.NumPad1:
                    return Key.NumPad1;
                case UIT.Events.Keyboard.Keys.NumPad2:
                    return Key.NumPad2;
                case UIT.Events.Keyboard.Keys.NumPad3:
                    return Key.NumPad3;
                case UIT.Events.Keyboard.Keys.NumPad4:
                    return Key.NumPad4;
                case UIT.Events.Keyboard.Keys.NumPad5:
                    return Key.NumPad5;
                case UIT.Events.Keyboard.Keys.NumPad6:
                    return Key.NumPad6;
                case UIT.Events.Keyboard.Keys.NumPad7:
                    return Key.NumPad7;
                case UIT.Events.Keyboard.Keys.NumPad8:
                    return Key.NumPad8;
                case UIT.Events.Keyboard.Keys.NumPad9:
                    return Key.NumPad9;
                case UIT.Events.Keyboard.Keys.Multiply:
                    return Key.Multiply;
                case UIT.Events.Keyboard.Keys.Add:
                    return Key.Add;
                case UIT.Events.Keyboard.Keys.Separator:
                    return Key.Separator;
                case UIT.Events.Keyboard.Keys.Subtract:
                    return Key.Subtract;
                case UIT.Events.Keyboard.Keys.Decimal:
                    return Key.Decimal;
                case UIT.Events.Keyboard.Keys.Divide:
                    return Key.Divide;
                case UIT.Events.Keyboard.Keys.F1:
                    return Key.F1;
                case UIT.Events.Keyboard.Keys.F2:
                    return Key.F2;
                case UIT.Events.Keyboard.Keys.F3:
                    return Key.F3;
                case UIT.Events.Keyboard.Keys.F4:
                    return Key.F4;
                case UIT.Events.Keyboard.Keys.F5:
                    return Key.F5;
                case UIT.Events.Keyboard.Keys.F6:
                    return Key.F6;
                case UIT.Events.Keyboard.Keys.F7:
                    return Key.F7;
                case UIT.Events.Keyboard.Keys.F8:
                    return Key.F8;
                case UIT.Events.Keyboard.Keys.F9:
                    return Key.F9;
                case UIT.Events.Keyboard.Keys.F10:
                    return Key.F10;
                case UIT.Events.Keyboard.Keys.F11:
                    return Key.F11;
                case UIT.Events.Keyboard.Keys.F12:
                    return Key.F12;
                case UIT.Events.Keyboard.Keys.F13:
                    return Key.F13;
                case UIT.Events.Keyboard.Keys.F14:
                    return Key.F14;
                case UIT.Events.Keyboard.Keys.F15:
                    return Key.F15;
                case UIT.Events.Keyboard.Keys.F16:
                    return Key.F16;
                case UIT.Events.Keyboard.Keys.F17:
                    return Key.F17;
                case UIT.Events.Keyboard.Keys.F18:
                    return Key.F18;
                case UIT.Events.Keyboard.Keys.F19:
                    return Key.F19;
                case UIT.Events.Keyboard.Keys.F20:
                    return Key.F20;
                case UIT.Events.Keyboard.Keys.F21:
                    return Key.F21;
                case UIT.Events.Keyboard.Keys.F22:
                    return Key.F22;
                case UIT.Events.Keyboard.Keys.F23:
                    return Key.F23;
                case UIT.Events.Keyboard.Keys.F24:
                    return Key.F24;
                case UIT.Events.Keyboard.Keys.NumLock:
                    return Key.NumLock;
                case UIT.Events.Keyboard.Keys.Scroll:
                    return Key.Scroll;
                case UIT.Events.Keyboard.Keys.LShiftKey:
                    return Key.LeftShift;
                case UIT.Events.Keyboard.Keys.RShiftKey:
                    return Key.RightShift;
                case UIT.Events.Keyboard.Keys.LControlKey:
                    return Key.LeftCtrl;
                case UIT.Events.Keyboard.Keys.RControlKey:
                    return Key.RightCtrl;
                case UIT.Events.Keyboard.Keys.LMenu:
                    return Key.LeftAlt;
                case UIT.Events.Keyboard.Keys.RMenu:
                    return Key.RightAlt;
                case UIT.Events.Keyboard.Keys.BrowserBack:
                    return Key.BrowserBack;
                case UIT.Events.Keyboard.Keys.BrowserForward:
                    return Key.BrowserForward;
                case UIT.Events.Keyboard.Keys.BrowserRefresh:
                    return Key.BrowserRefresh;
                case UIT.Events.Keyboard.Keys.BrowserStop:
                    return Key.BrowserStop;
                case UIT.Events.Keyboard.Keys.BrowserSearch:
                    return Key.BrowserSearch;
                case UIT.Events.Keyboard.Keys.BrowserFavorites:
                    return Key.BrowserFavorites;
                case UIT.Events.Keyboard.Keys.BrowserHome:
                    return Key.BrowserHome;
                case UIT.Events.Keyboard.Keys.VolumeMute:
                    return Key.VolumeMute;
                case UIT.Events.Keyboard.Keys.VolumeDown:
                    return Key.VolumeDown;
                case UIT.Events.Keyboard.Keys.VolumeUp:
                    return Key.VolumeUp;
                case UIT.Events.Keyboard.Keys.MediaNextTrack:
                    return Key.MediaNextTrack;
                case UIT.Events.Keyboard.Keys.MediaPreviousTrack:
                    return Key.MediaPreviousTrack;
                case UIT.Events.Keyboard.Keys.MediaStop:
                    return Key.MediaStop;
                case UIT.Events.Keyboard.Keys.MediaPlayPause:
                    return Key.MediaPlayPause;
                case UIT.Events.Keyboard.Keys.LaunchMail:
                    return Key.LaunchMail;
                case UIT.Events.Keyboard.Keys.SelectMedia:
                    return Key.SelectMedia;
                case UIT.Events.Keyboard.Keys.LaunchApplication1:
                    return Key.LaunchApplication1;
                case UIT.Events.Keyboard.Keys.LaunchApplication2:
                    return Key.LaunchApplication2;
                case UIT.Events.Keyboard.Keys.Oem1:
                    return Key.Oem1;
                case UIT.Events.Keyboard.Keys.Oemplus:
                    return Key.OemPlus;
                case UIT.Events.Keyboard.Keys.Oemcomma:
                    return Key.OemComma;
                case UIT.Events.Keyboard.Keys.OemMinus:
                    return Key.OemMinus;
                case UIT.Events.Keyboard.Keys.OemPeriod:
                    return Key.OemPeriod;
                case UIT.Events.Keyboard.Keys.Oem2:
                    return Key.Oem2;
                case UIT.Events.Keyboard.Keys.Oem3:
                    return Key.Oem3;
                case UIT.Events.Keyboard.Keys.Oem4:
                    return Key.Oem4;
                case UIT.Events.Keyboard.Keys.Oem5:
                    return Key.Oem5;
                case UIT.Events.Keyboard.Keys.Oem6:
                    return Key.Oem6;
                case UIT.Events.Keyboard.Keys.Oem7:
                    return Key.Oem7;
                case UIT.Events.Keyboard.Keys.Oem8:
                    return Key.Oem8;
                case UIT.Events.Keyboard.Keys.Oem102:
                    return Key.Oem102;
                case UIT.Events.Keyboard.Keys.Attn:
                    return Key.Attn;
                case UIT.Events.Keyboard.Keys.Crsel:
                    return Key.CrSel;
                case UIT.Events.Keyboard.Keys.Exsel:
                    return Key.ExSel;
                case UIT.Events.Keyboard.Keys.EraseEof:
                    return Key.EraseEof;
                case UIT.Events.Keyboard.Keys.Play:
                    return Key.Play;
                case UIT.Events.Keyboard.Keys.Zoom:
                    return Key.Zoom;
                case UIT.Events.Keyboard.Keys.NoName:
                    return Key.None;
                case UIT.Events.Keyboard.Keys.Pa1:
                    return Key.Pa1;
                case UIT.Events.Keyboard.Keys.OemClear:
                    return Key.OemClear;
            }
            return Key.None;
        }

        internal static ModifierKeys Convert(Events.Keyboard.KeyModifiers keyModifiers)
        {
            switch (keyModifiers)
            {
                case UIT.Events.Keyboard.KeyModifiers.Shift:
                    return ModifierKeys.Shift;
                case UIT.Events.Keyboard.KeyModifiers.Alt:
                    return ModifierKeys.Alt;
                case UIT.Events.Keyboard.KeyModifiers.Control:
                    return ModifierKeys.Control;
            }
            return ModifierKeys.None;
        }
    }
}
